import java.util.*;
import java.math.*;

public class Learn {
    public static void main(String[] args) {
        //while grammar example
//        //read inputs
//        Scanner in = new Scanner(System.in);
//
//        System.out.print("How much money do you need to retire? ");
//        double goal = in.nextDouble();
//
//        System.out.print("How much money will you contribute every year? ");
//        double payment = in.nextDouble();
//
//        System.out.print("Interest rate in %: ");
//        double interestRate = in.nextDouble();
//
//        double balance = 0;
//        int years = 0;
//
//        //update account alance while goal isn's reached
//        while(balance < goal)
//        {
//            //add this year's payment and interest
//            balance += payment;
//            double interest = balance * interestRate / 100;
//            balance += interest;
//            years++;
//        }
//
//        System.out.println("You can retire in " + years + "years.");

        //do/while grammar example
//        Scanner in = new Scanner(System.in);
//
//        System.out.println("How much money will you contribute every year?");
//        double payment = in.nextDouble();
//        System.out.print("Interest rate in %:");
//        double interestRate = in.nextDouble();
//
//        double balance = 0;
//        int year = 0;
//
//        String input;
//
//        // update account balance while user isn's ready to retire
//        do {
//            // add this year's payment and interest
//            balance += payment;
//            double interest = balance * interestRate / 100;
//            balance += interest;
//
//            year++;
//
//            // print current balance
//            System.out.printf("After year %d, your balance is %,.2f%n", year, balance);
//
//            // ask if ready to retire and get input
//            System.out.print("Ready to retire? (Y/N)");
//            input = in.next();
//        }while(input.equals("N"));
//
//    }

        //for grammar example
//        Scanner in = new Scanner(System.in);
//
//        System.out.print("How many numbers do you need to draw? ");
//        int k = in.nextInt();
//
//        System.out.println("What is the highest number you can draw? ");
//        int n = in.nextInt();
//
//        int lotteryOdds = 1;
//        for(int i = 1; i <= k; i++)
//        {
//            lotteryOdds = lotteryOdds * (n - i + 1) / i;
//        }
//        System.out.println("Yout odds are 1 in " + lotteryOdds + ". Good luck!");
//    }

        //BigIntegerTest example
//        Scanner in = new Scanner(System.in);
//
//        System.out.print("How many numbers do you need to draw? ");
//        int k = in.nextInt();
//
//        System.out.print("What is the highest number you can draw? ");
//        int n = in.nextInt();
//
//        //compute binomial coefficient n*(n-1)*(n-1)*...*(n-k+1)/(1*2*3*...*k)
//
//        BigInteger lotteryOdds = BigInteger.valueOf(1);
//
//        for(int i = 1; i <= k; i++)
//        {
//            lotteryOdds = lotteryOdds.multiply(BigInteger.valueOf(n - i + 1)).divide(BigInteger.valueOf(i));
//        }
//        System.out.println("Your odds are 1 in " + lotteryOdds + ". Good luck!");
//    }

        //Array example
//        Scanner in = new Scanner(System.in);
//        System.out.print("How many numbers do you need to draw? ");
//        int k = in.nextInt();
//
//        System.out.print("What is the highest number you can draw?");
//        int n = in.nextInt();
//
//        //fill an array with numbers 1 2 3 . . . n
//        int[] numbers = new int[n];
//        for(int i = 0; i < numbers.length; i++)
//        {
//            numbers[i] = i + 1;
//        }
//
//        // draw k numbers and put them into a second array
//        int [] result = new int[k];
//        for(int i = 0; i < result.length; i++)
//        {
//            // make a random index between 0 and n - 1
//            int r = (int)(Math.random() * n);
//
//            // pick the element at the random location
//            result[i] = numbers[r];
//
//            // move the last element into the random location
//            numbers[r] = numbers[n - 1];
//            n--;
//        }
//
//        // print the sorted array
//        Arrays.sort(result);
//        System.out.println("Bet the following combination. It'll make you rich!");
//        for(int r: result)
//        {
//            System.out.println(r);
//        }

        //This program shows how to store tabular data in a 2D array
//        final double STARTRATE = 10;
//        final int NRATES = 6;
//        final int NYERS = 10;
//
//        // set interest rates to 10 . . . 15%
//        double[] interestRate = new double[NRATES];
//        for (int j = 0; j < interestRate.length; j++) {
//            interestRate[j] = (STARTRATE + j) / 100.0;
//        }
//
//        double[][] balances = new double[NYERS][NRATES];
//
//        //set initial balances to 10000
//        for (int j = 0; j < balances[0].length; j++) {
//            balances[0][j] = 10000;
//        }
//
//        // compute interest for future years
//        for (int i = 1; i < balances.length; i++)
//        {
//            for(int j = 0; j < balances[i].length; j++)
//            {
//                //get last year's balances from previous row
//                double oldBalance = balances[i - 1][j];
//
//                // compute interest
//                double interest = oldBalance * interestRate[j];
//
//                // compute this year's balances
//                balances[i][j] = oldBalance + interest;
//            }
//        }
//
//        // print one row of interest rates
//        for(int j = 0; j < interestRate.length; j++)
//        {
//            System.out.printf("%9.0f%%", 100 * interestRate[j]);
//        }
//
//        System.out.println();
//
//        // print balance table
//        for (double[] row: balances)
//        {
//            // print table row
//            for (double b: row)
//            {
//                System.out.printf("%10.2f", b);
//            }
//            System.out.println();
//        }

        //This program demonstrates a triangular array.
        final int NMAX = 10;

        // allocate triangular array
        int[][] odds = new int[NMAX + 1][];

        for(int n = 0; n <= NMAX; n++)
        {

            odds[n] = new int[n + 1];
        }

        // fill triangular array
        for (int n = 0; n < odds.length; n++)
        {
            for(int k = 0; k < odds[n].length; k++)
            {
                // compute binomial coefficient n*(n-1)*(n-2)*...*(n-k+1)/(1*2*3*...*k)
                int lotteryOdds = 1;
                for(int i = 1; i <= k; i++)
                {
                    lotteryOdds = lotteryOdds*(n - i + 1) / i;
                }
                odds[n][k] = lotteryOdds;
            }
            // print triangular array
            for(int[] row: odds)
            {
                for (int odd : row)
                {
                    System.out.printf("%4d", odd);
                }
                System.out.println();
            }
        }
        System.out.println();

    }

}
